package www.shuang.head.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import www.shuang.common.controller.BaseController;
import www.shuang.common.util.PageInfoUtil;
import www.shuang.investor.pojo.AInvestor;
import www.shuang.investor.service.IAInvestorService;

@Controller
@RequestMapping("/head/investor/")
public class InvestorHeadController extends BaseController
{
	@Resource
	private IAInvestorService investorService; 
		//出资方列表
	@RequestMapping("/investorList.htm")
	public String investorList(HttpServletRequest request){
		//接收参数
		String keyword=request.getParameter("keyword");
		String st=request.getParameter("st");
		String ed=request.getParameter("ed");
		String coopType=request.getParameter("coopType");
		/*if(status == null){
			status="";
		}*/
		if(st == null){
			st="";
		}
		if(ed == null){
			ed="";
		}
		if(coopType == null){
			coopType="";
		}
		Date stDate = null;
		Date edDate= null;
		if(!"".equalsIgnoreCase(st)&&!"".equalsIgnoreCase(ed)){
			stDate=this.dateFormatUtil.parseDate(st);
			edDate=this.dateFormatUtil.parseDate(ed);
		}
		PageInfoUtil pageInfoUtil =this.proccedPage(request);
		Map<String, Object> condMap=new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		condMap.put("status", "1");
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		condMap.put("coopType", coopType);
		List<AInvestor> investorList = this.investorService.findCondListAInvestorService(pageInfoUtil, condMap);
		//放入作用域中
		request.setAttribute("investorList", investorList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		//
		request.setAttribute("keyword", keyword);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		request.setAttribute("coopType", coopType);
		
		return "/head/investor/investorList";
	}
	//出资方详情
	@RequestMapping("/investorInfo.htm")
	public String investorInfo(@RequestParam String iid,HttpServletRequest request){
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.put("id", iid);
		AInvestor investor = this.investorService.findOneAInvestorService(condMap);
		
				request.setAttribute("investor", investor);
		return "/head/investor/investorInfo";
	}
	
}
